﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典明细</title>
    <#include "../common/link.ftl"/>

    <script>

        $(function () {

            $("#dic a[data-id = '${(qo.parentId)!}']").addClass("active");  //做高亮，选择器是：id为dic的元素下的a元素的属性data-id=XX


            /*------------------------删除-------------------------------*/

            $(".btn-delete").click(function () {

                var $id = $(this).data("id");

                $.messager.confirm("温馨提示", "确定要删除吗？", function () {
                    $.get("/systemDictionaryItem/delete", {id: $id}, handlerMessage);
                });
            });

            /*----------------------模态框---------------------------*/

            $(".btn-input").click(function () {
                $("#editForm input").val("");  //清空模态框数据
                var sdi = $(this).data("sdi"); //获取明细数据
                if (sdi) {
                    $("#id").val(sdi.id);          //回显数据
                    $("#title").val(sdi.title);         //回显数据
                    $("#sequence").val(sdi.sequence);         //回显数据
                }
                $("#parentId").val(${(qo.parentId)!});
                $("#parentName").val($("#dic .active").text())  //获取高亮的元素的文本


                $('#input-modal').modal('show')     //显示模态框
            });

            $("#editForm").ajaxForm(handlerMessage);

        });

    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl"/>

    <!--菜单回显-->
    <#assign currentMenu="systemDictionaryItem"/>

    <#include "../common/menu.ftl"/>
    <div class="content-wrapper">
        <section class="content-header">
            <h1>字典明细</h1>
        </section>
        <section class="content">
            <div class="box">
                <div class="row" style="margin:20px">
                    <div class="col-xs-3">
                        <div class="panel panel-default">
                            <div class="panel-heading">字典目录</div>
                            <div class="panel-body">
                                <div class="list-group" id="dic">
                                    <#list systemDictionaries as sd>
                                        <a href="/systemDictionaryItem/list?parentId=${sd.id}" data-id="${sd.id}"
                                           class="list-group-item">${sd.title}</a>
                                    </#list>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-9">
                        <form class="form-inline" id="searchForm" action="/systemDictionaryItem/list" method="post">
                            <input type="hidden" name="currentPage" id="currentPage" value="1">
                            <input type="hidden" name="parentId" value="${(qo.parentId)!}">
                            <label for="keyword" class="control-label">关键字：</label>
                            <input type="text" id="keyword" placeholder="请输入标题关键字" name="keyword"
                                   value="${(qo.keyword)!}">
                            <button id="btn_query" class="btn btn-primary"><span
                                        class="glyphicon glyphicon-search"></span> 查询
                            </button>
                            <a href="#" class="btn btn-success btn-input" style="margin: 10px">
                                <span class="glyphicon glyphicon-plus"></span> 添加
                            </a>

                        </form>
                        <div class="box-body table-responsive no-padding ">
                            <table class="table table-hover table-bordered">
                                <tr>
                                    <th>编号</th>
                                    <th>标题</th>
                                    <th>序号</th>
                                    <th>操作</th>
                                </tr>
                                <#list pageInfo.list as sdi>
                                    <tr>
                                        <td>${sdi_index+1}</td>
                                        <td>${sdi.title}</td>
                                        <td>${sdi.sequence}</td>
                                        <td>
                                            <a href="#" id="editButton" data-sdi='${sdi.json}'
                                               class="btn btn-info btn-xs btn-input">
                                                <span class="glyphicon glyphicon-pencil"></span> 编辑
                                            </a>
                                            <a href="#" data-id="${sdi.id}" class="btn btn-danger btn-xs btn-delete">
                                                <span class="glyphicon glyphicon-trash"></span> 删除
                                            </a>
                                        </td>
                                    </tr>
                                </#list>
                            </table>
                            <!--分页-->
                            <#include "../common/page.ftl"/>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl"/>
</div>
<#---------------------模态框------------------------------->
<div class="modal fade " id="input-modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">添加或编辑目录明细</h4>
            </div>
            <form class="form-horizontal" action="/systemDictionaryItem/saveOrUpdate" method="post" id="editForm">
                <div class="modal-body">
                    <p>
                        <input type="hidden" id="id" name="id">

                        <input type="hidden" id="parentId" name="sd.id">

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sd_title" class="col-sm-3 control-label">目录：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="parentName" readonly>
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-3 control-label">标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="title" name="title"
                                   placeholder="请输入标题">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-3 control-label">序列：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" id="sequence" name="sequence"
                                   placeholder="请输入编码">
                        </div>
                    </div>
                    </p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button id="submitBtn" type="submit" class="btn btn-primary">保存</button>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>
